/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.playground.core.entity;

import java.util.Date;
import java.util.List;

/**
 *
 * @author Tiago Peres
 */
public class Room {
    // unique identifier
    private final long id;
    // the game hosted by this room
    private Game game;
    // the maximum number of players
    private int maxPlayers;
    private RoomStatus status;
    // time when the room status changed to "waitingForPlayersConfirmation"
    private Date waitingForPlayersConfirmationSince;
    private List<LoggedPlayer> players;
    private GameTitle gameTitle;
    
    public Room (long id){
        this.id = id;
    }
    
    public Room (){
        id = -1;
    }

    // getters and setters
    public Game getGame() {
        return game;
    }

    public int getMaxPlayers() {
        return maxPlayers;
    }

    public RoomStatus getStatus() {
        return status;
    }

    public void setStatus(RoomStatus status) {
        this.status = status;
    }

    public Date getWaitingForPlayersConfirmationSince() {
        return waitingForPlayersConfirmationSince;
    }

    public void setWaitingForPlayersConfirmationSince(Date waitingForPlayersConfirmationSince) {
        this.waitingForPlayersConfirmationSince = waitingForPlayersConfirmationSince;
    }

    public long getId() {
        return id;
    }

    public void setGame(Game game) {
        this.game = game;
    }

    public void setMaxPlayers(int maxPlayers) {
        this.maxPlayers = maxPlayers;
    }

    public List<LoggedPlayer> getPlayers() {
        return players;
    }

    public void setPlayers(List<LoggedPlayer> players) {
        this.players = players;
    }

    public GameTitle getGameTitle() {
        return gameTitle;
    }

    public void setGameTitle(GameTitle gameTitle) {
        this.gameTitle = gameTitle;
    }
    
    @Override
    public boolean equals(Object o){
        if (null != o && o.getClass().equals(this.getClass())){
            return ((Room) o).getId() == getId();
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 19 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    }
    
}
